﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace T01WPF
{
    /// <summary>
    /// LoginWindow1.xaml 的交互逻辑
    /// </summary>
    public partial class LoginWindow1 : Window
    {
        public LoginWindow1()
        {
            InitializeComponent();
        }

        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            //獲取需要處理的界面控件的數據
            string username = TxtUsername.Text.Trim();
            string password = TxtPassword.Password.Trim();
            //認證邏輯
            //if(username.Equals ("admin")&& password.Equals("admin"))
            if(UserDao.LoginCheck (username ,password )>0)
            {
                MessageBox.Show("登錄成功");
                var mainWindow = new MainWindow();
                mainWindow.Title = "用戶" + username + "登錄";
                mainWindow.Show();
                //關閉登錄窗口
                this.Close();
            }
            else
            {
                MessageBox.Show("用戶名或密碼錯誤！");
            }
        }
    }
}
